const schedule = require('node-schedule');
const Promise = require('bluebird');
const moment = require('moment');
const qs = require('qs');
const axios = require('axios');

module.exports = function (storage, config) {

    /**
     * 十分钟执行一次
     */
    let minutesHandler = function () {

    }
    let minutesJob = schedule.scheduleJob('0 */10 * * * *', minutesHandler);

    /**
     * 每天凌晨
     */
    let dayHandler = function () {
        axios.post(config.domain + '/api/webservice/v1/tasks/update_wechat_tags?key=' + config.webservice_key).then(function (response) {
            console.error('webservice update_wechat_tags result', response.data);
        });

        axios.post(config.domain + '/api/webservice/v1/tasks/auto_settle?key=' + config.webservice_key).then(function (response) {
            console.error('webservice auto_settle result', response.data);
        });

        return {success: true};
    }
    let dayJob = schedule.scheduleJob('0 0 0 * * *', dayHandler);

    /**
     * 每月一号凌晨
     */
    let monthHandler = function () {

    }
    let monthJob = schedule.scheduleJob('0 0 0 1 * *', monthHandler);

    return {
        minutesHandler: minutesHandler,
        dayHandler: dayHandler,
        monthHandler: monthHandler
    }
};